<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class SwtOrder extends Model
{
    use HasFactory;
    use HasDateTimeFormatter;

    protected $table = 'swt_order';

    protected $guarded = [];

    public function user()
    {
        return $this->belongsTo(SwtUser::class);
    }

    public function machine()
    {
        return $this->belongsTo(SwtMachine::class) -> withTrashed();
    }

    public function goods()
    {
        return $this->hasMany(SwtOrderGoods::class,'order_id','id');
    }

    public function dhe_order()
    {
        return $this->hasOne(SwtDheOrder::class,'order_id');
    }

    public function merchant_profit()
    {
        return $this->hasOne(SwtMerchantProfit::class,'order_id');
    }

    public function bj_open()
    {
        return $this->hasOne(SwtBjOpen::class,'order_id');
    }
}
